<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>字典管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#value").focus();
			$("#inputForm").validate({
				rules: {
					activityName: {remote: "${ctx}/app/mmsActivity/checkActivityName?oldActivityName=" + encodeURIComponent('${mmsActivity.activityName}')}
				},
				messages: {
					activityName: {remote: "活动名称相同,不能重复创建"}
				},
				submitHandler: function(form){
					 var id=$("#id").val();
					 var beginDate=$("#beginDate").val(); 
					 var endDate=$("#endDate").val(); 
					 var d1 = new Date(beginDate.replace(/\-/g, "\/")); 
					 var d2 = new Date(endDate.replace(/\-/g, "\/")); 
					  if(beginDate!=""&&endDate!=""&&d1 >d2) 
					 { 
					  alert("开始时间不能大于结束时间！"); 
					  return false; 
					 }
					$.post("checkDate",{id:id,beginDate:beginDate,endDate:endDate},function(data){
						if(data=='1'){
							alert("此时间段内可能有其他活动！"); 
							return false;
						}else{
							loading('正在提交，请稍等...');
							form.submit();
						}
					})
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/app/mmsActivity/">活动列表</a></li>
		<li class="active"><a href="${ctx}/app/mmsActivity/form">活动${not empty mmsActivity.id?'修改':'添加'}</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="mmsActivity" action="${ctx}/app/mmsActivity/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">活动名称</label>
			<div class="controls">
				<form:input path="activityName" htmlEscape="false" maxlength="50" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">默认考种</label>
			<div class="controls">
				<form:select path="examType" class="input-small required" >
					<form:options items="${fns:getDictList('mmsActivity')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">活动起止时间</label>
			<div class="controls">
				<input id="beginDate" name="beginDate" type="text" readonly="readonly" maxlength="20" class="input-mini Wdate required"
				value="<fmt:formatDate value="${mmsActivity.beginDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			--&nbsp;<input id="endDate" name="endDate" type="text" readonly="readonly" maxlength="20" class="input-mini Wdate required"
				value="<fmt:formatDate value="${mmsActivity.endDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">活动关联店铺ID：</label>
			<div class="controls">
				 <form:input path="shopId" htmlEscape="false" maxlength="50" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">活动关联店铺名称</label>
			<div class="controls">
				<form:input path="shopName" htmlEscape="false" maxlength="50" class="required"/>
			</div>
		</div>
		<%-- <div class="control-group">
			<label class="control-label">创建时间</label>
			<div class="controls">
				  <input  id="createDate" name="createDate" type="text" 
				  value="<fmt:formatDate value="${mmsActivity.createDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> 
				<form:input path="createDate" v htmlEscape="true" maxlength="20" class="required" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div> --%>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>